﻿using System.ComponentModel;
using System.Windows.Media;

namespace LifeV2.Model
{
    public class Creature : ILifeForm
    {
        private int _health;
        private int _x;

        private int _y;

        public Creature(World world, int x, int y)
        {
            worldRef = world;
            X = x;
            Y = y;
            Health = 0;
        }

        public Brush Fill
        {
            get { return Brushes.DarkGreen; }
        }

        #region ILifeForm Members

        public event PropertyChangedEventHandler PropertyChanged;

        public World worldRef { get; set; }

        public int X
        {
            get { return _x; }
            set
            {
                _x = value;
                RaisePropertyChanged("X");
            }
        }

        public int Y
        {
            get { return _y; }
            set
            {
                _y = value;
                RaisePropertyChanged("Y");
            }
        }

        public int Health
        {
            get { return _health; }
            set
            {
                _health = value;
                RaisePropertyChanged("Health");
            }
        }

        public bool IsAlive
        {
            get { return Health > 0; }
        }

        public void Act()
        {
        }

        #endregion

        protected void RaisePropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}